<template>
  <div>
    <el-dialog
      title="编辑状态"
      :visible.sync="dialogVisible"
      width="30%"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="状态名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="handleOk">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
  import {createOrEditStatus} from "@/api/set";

  export default {
    data() {
      return {
        dialogVisible: false,
        form: {
          id: '',
          name: '',
        },
        options: [],
        rules: {
          name: [
            {required: true, message: '请输入状态名称', trigger: 'blur'},
          ],
        }
      }
    },
    methods: {
      show1(id) {
        this.form = {
          id: id.id,
          name: id.name,
        }
        this.dialogVisible = true
      },
      handleOk() {
        createOrEditStatus(this.form).then(res => {
          if (res.status === 200) {
            this.$message.success("编辑成功")
            this.$emit('Ok')
            this.dialogVisible = false
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
